/*
* 文件：SkipUnityLogo.cs
* 作者：王阳
* 时间：2019-5-20
* 描述：免费版Unity强制跳过发布的程序的启动画面(UnityLogo)
*/
//#define ENABLED
#if ENABLED
using UnityEngine;
using UnityEngine.Rendering;

namespace UnityX
{
    internal class SkipUnityLogo
    {
#if UNITY_WEBGL
        [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
        private static void BeforeSplashScreen()
        {
            Application.focusChanged += FocusChanged;
        }
        private static void FocusChanged(bool obj)
        {
            Application.focusChanged -= FocusChanged;
            SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
        }
#else
        [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
        private static void BeforeSplashScreen()
        {
            System.Threading.Tasks.Task.Run(AsyncSkip);
        }
        private static void AsyncSkip()
        {
            //System.Threading.Thread.Sleep(10);
            SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
        }
#endif
    }
}
#endif